import axios from "axios";
import { ASSIGNMENTS_MODULE } from "./_prefix";


/**
 *
 * @param  courseId 课程id
 * @returns  课程题目列表
 */
export const getAssignments = courseId=>{

  console.log(courseId);
  return axios.get(`${ASSIGNMENTS_MODULE}/${courseId}`).then(
    res=>{
      return res.data;
    }
  )
}


/**
 * 增加
 * @param payload
 * @returns {Promise<AxiosResponse<any>>}
 */
export  const addAssignment = payload=>{
  console.log(payload)
  return axios.post(`${ASSIGNMENTS_MODULE}/add`,payload).then(
    res=>{
      return res.data;
    }
  )
}


/**
 * 修改题目信息
 * @param payload
 * @returns {Promise<AxiosResponse<any>>}
 */
export const editAssignment = payload=>{
  return axios.post(`${ASSIGNMENTS_MODULE}/edit`,payload).then(
    res=>{
      return res.data;
    }
  )
}


/**
 * 删除题目
 * @param payload
 * @returns {Promise<AxiosResponse<any>>}
 */
export const deleteAssignment = payload=>{
  return axios.get(`${ASSIGNMENTS_MODULE}/delete/${payload}`,).then(
    res=>{
      return res.data;
    }
  )
}